// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "PatternViewerDlg.h"
#include "NameTblViewerDlg.h"
#include "SpriteViewerDlg.h"

class CMainFrame : public CFrameWindowImpl< CMainFrame >,
                   public CMessageFilter, public CIdleHandler
{
public:
                    DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)

  CEmu_testView     m_view;

  CCommandBarCtrl   m_CmdBar;

  virtual BOOL      PreTranslateMessage(MSG* pMsg);
  virtual BOOL      OnIdle();

  BEGIN_MSG_MAP(CMainFrame)
    MESSAGE_HANDLER(WM_CREATE, OnCreate)

    COMMAND_ID_HANDLER(ID_FILE_OPEN, OnOpenFile)
    COMMAND_ID_HANDLER(ID_FILE_CLOSE, OnCloseFile)

    COMMAND_ID_HANDLER(ID_APP_EXIT, OnFileExit)

    COMMAND_ID_HANDLER(ID_VIEW_PATTERN_TABLE, OnViewPatternTbl)
    COMMAND_ID_HANDLER(ID_VIEW_NAMETABLE, OnViewNameTbl)
    COMMAND_ID_HANDLER(ID_VIEW_SPRITE, OnViewSprite)

    COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
    CHAIN_MSG_MAP(CFrameWindowImpl < CMainFrame>)
  END_MSG_MAP()

  // Handler prototypes (uncomment arguments if needed):
  //  LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  //  LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
  //  LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

  LRESULT           OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/,
                             LPARAM /*lParam*/, BOOL& /*bHandled*/);
  LRESULT           OnTimer(UINT /*uMsg*/, WPARAM /*wParam*/,
                            LPARAM /*lParam*/, BOOL& /*bHandled*/);

  LRESULT           OnOpenFile(WORD /*wNotifyCode*/, WORD /*wID*/,
                               HWND /*hWndCtl*/, BOOL& /*bHandled*/);
  LRESULT           OnCloseFile(WORD /*wNotifyCode*/, WORD /*wID*/,
                                HWND /*hWndCtl*/, BOOL& /*bHandled*/);

  LRESULT           OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/,
                               HWND /*hWndCtl*/, BOOL& /*bHandled*/);
  LRESULT           OnFileNew(WORD /*wNotifyCode*/, WORD /*wID*/,
                              HWND /*hWndCtl*/, BOOL& /*bHandled*/);
  LRESULT           OnViewPatternTbl(WORD /*wNotifyCode*/, WORD /*wID*/,
                                     HWND /*hWndCtl*/, BOOL& /*bHandled*/);
  LRESULT           OnViewNameTbl(WORD /*wNotifyCode*/, WORD /*wID*/,
                                  HWND /*hWndCtl*/, BOOL& /*bHandled*/);
  LRESULT           OnViewSprite(WORD /*wNotifyCode*/, WORD /*wID*/,
                                 HWND /*hWndCtl*/, BOOL& /*bHandled*/);
  LRESULT           OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/,
                               HWND /*hWndCtl*/, BOOL& /*bHandled*/);

  void              OnKeyDown(WPARAM wParam);
  void              OnKeyUp(WPARAM wParam);

  void              SetMemuState();
  void              DrawFrame();

  void              SetTitle();

private:
  CPatternViewerDlg m_PatternViewer;
  CNameTblViewerDlg m_NameTblViewer;
  CSpriteViewerDlg  m_SpriteViewer;
  bool              m_Start;

  wchar_t           m_RomName[100];
};
